package com.example.work_sqlite_note;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.Nullable;

import java.util.List;

public class TempAdapter extends ArrayAdapter<Temp> {
    private int resourceId;
    private TextView textViewTitle;
    private TextView textViewContent;

    public TempAdapter(Context context, int resource,
                       List<Temp> objects) {
        super(context, resource, objects);
        resourceId = resource;
    }


    @Override
    public View getView(int position, @Nullable View convertView, ViewGroup parent) {
        Temp temp = getItem(position);//获取当前实例
        View view = LayoutInflater.from(getContext()).inflate(resourceId
                , parent, false);
        textViewTitle = view.findViewById(R.id.item_title);
        textViewContent = view.findViewById(R.id.item_comtent);
        textViewTitle.setText(temp.getTitle());
        textViewContent.setText(temp.getContent());
        return view;


    }
}
